package com.sweet;

public class Result<T> {
    private Integer code;
    private String message;
    private T result;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public Result(Integer code, String message, T result) {
        this.code = code;
        this.message = message;
        this.result = result;
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result() {
    }

    public static <T> Result ok() {
        return new Result(200, "success");
    }

    public static <T> Result ok(T data) {
        return new Result(200, "success", data);
    }

    public static <T> Result error(Integer code, String message, T data) {
        return new Result(code, message, data);
    }
    public static <T> Result error(T data) {
        return new Result(1000, "请求失败", data);
    }
}
